<?php 
	session_start();
	$var1= $_SESSION["registrado"];
	$var2= $_SESSION["administrador"];
	if ($var1 == null): {
		echo ("User not registered");
	} elseif ($var2 == 0): { 
			echo ("User without permissions");
	} else : {
?>


<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-responsive.css" rel="stylesheet"	media="screen">

<title>My project manager</title>



</head>

<body>
<?php include ('configuration.php'); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap.js"></script>


<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container-fluid">
			<button type="button" class="btn btn-navbar" data-toggle="collapse"
				data-target=".nav-collapse">
				<span class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="brand" href="http://localhost/bases--grupo10/homeAdmin.php?">My project manager</a>
			<div class="nav-collapse collapse">
				<p class="navbar-text pull-right">
				
					<a href="http://localhost/bases--grupo10/logout.php?" class="navbar-link">Log out</a>
				</p>
				<ul class="nav">
					<li class="active"><a href="http://localhost/bases--grupo10/homeAdmin.php?">Home</a></li>
					<li><a href="http://localhost/bases--grupo10/about.php?">About</a></li>
					<li><a href="http://localhost/bases--grupo10/contact.php?">Contact</a></li>
				</ul>
			</div>
		</div> 
	</div>
</div>
		


<?php
	$id_member=$_POST['select_member'];  
	$id_project = $_SESSION["id_proj"];  
	$no_actualizar=0;
	
	if ($id_member != 0): {
	
		//consulto si el miembro seleccionado ya est� inclu�do en el proyecto 
		$q = mysql_query("SELECT id_member_participate FROM participate WHERE id_member_participate = '$id_member' 
							AND id_project_participate = '$id_project'");
		$result = mysql_fetch_assoc($q);
		$responsible = $result['id_member_participate'];
		
		if ($responsible != 0): {
			$no_actualizar=1;
			echo "<h1 style='position:absolute;top:150px;left:50px;font-weight:bold'><font size='5'><u>This member belonged to the project previously</u></font></h1>";
			echo "<a class='btn btn-primary' type='button' href='http://localhost/bases--grupo10/modifyProject3_addMember.php?' style='position:absolute;top:250px;left:50px'>Back</a>";
		} else: {
			$q1 = mysql_query("INSERT INTO participate (id_project_participate, id_member_participate, is_responsible) VALUES ('$id_project', '$id_member', 0)");
			echo "<h1 class='muted'  style='position:absolute;top:50px;left:50px;'>Member <u>added to the project</u> </h1>";
		 }endif;
		
		if ($no_actualizar!=1): {
		?>
			<a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/modifyProject3_addMember.php?" style="position:absolute;top:200px;left:200px">Add more</a>
			<a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/modifyProject3.php?" style="position:absolute;top:250px;left:225px">Finish</a>
		<?php 
		}endif;
		
	} else: {
		echo "<h1 style='position:absolute;top:130px;left:50px;font-weight:bold'><font size='5'><u> You must select one member for adding to project</u></font></h1>"; 
		echo "<a class='btn btn-primary' type='button' href='http://localhost/bases--grupo10/modifyProject3_addMember.php?' style='position:absolute;top:250px;left:50px'>Back</a>";
	} endif;?>	

</body>
</html>			

<?php }endif;?>